package bin_tree.oj;

import java.util.ArrayList;
import java.util.List;

public class Num897 {
    public TreeNode increasingBST(TreeNode root) {
        List<Integer> res = new ArrayList<Integer>();
        inordor(root,res);

        TreeNode dummyRoot = new TreeNode(-1);
        TreeNode currRoot = dummyRoot;
        for (int val:
             res) {
            currRoot.right = new TreeNode(val);
            currRoot = currRoot.right;
        }
        return dummyRoot.right;
    }
    public void inordor(TreeNode root, List<Integer> res){
        if (root == null){
            return;
        }
        inordor(root.left,res);
        res.add(root.val);
        inordor(root.right,res);
    }
}
